<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8">
<title>news 编辑</title>
<link rel="stylesheet" href="../../js/layui/css/layui.css"  media="all">
<script type="text/javascript" src="../../js/layui/layui.js"></script>
<script type="text/javascript" src="../../js/layui/lay/lib/jquery.js"></script>
<style type="text/css">
	.formstyle{
		position: relative;
		top: 50px;
		width:400px;
		margin-top:50px;
		padding: auto;
		font-family: cursive;
	}
</style>
</head>
<body>
	<div style="margin-top:50px;"></div>
	<div class="formstyle">
		<div class="layui-form-item">
			<label class="layui-form-label">标题</label>
			<div class="layui-input-inline">
				<input type="text" name="title" id="title" required
					lay-verify="required" placeholder="请输入标题" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">摘要</label>
			<div class="layui-input-inline">
				<input type="text" name="summary" id="summary" required
					lay-verify="required" placeholder="请输入摘要" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">作者</label>
			<div class="layui-input-inline">
				<input type="text" name="addPeopleName" id="addPeopleName" required
					lay-verify="required" placeholder="请输入作者" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">正文:</label>
			<div class="layui-input-block" style="margin-left: 1px;">
				<textarea name="content" id="content" placeholder="请输入内容"
					class="layui-textarea"></textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn"  id="submit">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</div>	
	<script type="text/javascript"
		src="../../js/jquery-1.7.2.min.js"></script>
	<script>
		//Demo
		layui.use([ 'form','layer', 'layedit' ], function() {
			var form = layui.form();
			var layedit = layui.layedit;
			var layer = layui.layer;

			var index = layedit.build('content', {
				height : 500
			}); //建立编辑器
			layedit.sync(index)

			$("#submit").click(function() {
				
				$.ajax({
					url : '../../news/addNews',
					data : {
						'title' : $("#title").val(),
						'summary' : $("#summary").val(),
						'addPeopleName' : $("#addPeopleName").val(),
						'content' : layedit.getContent(index)
					},
					type : 'POST',
					dataType : 'json',
					success : function(res) {
						layer.msg("haha");
						console.log(res);
					}
				});
			});

		});
	</script>
</body>
</html>